package io.gitee.hechenl.fastiotreport.config;

/*import io.gitee.hechenl.fastiotreport.util.PageContext;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;*/

/*@Interceptor
@Component
public class PageRequestInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        // 从请求中获取分页参数
        Integer current = getParameter(request, "current", 1);
        Integer size = getParameter(request, "size", 10);

        PageContext.setCurrentPage(new Page<>(current, size));
        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response,
                                Object handler, Exception ex) {
        PageContext.clear();
    }

    private Integer getParameter(HttpServletRequest request, String name, Integer defaultValue) {
        String value = request.getParameter(name);
        return StringUtils.hasText(value) ? Integer.valueOf(value) : defaultValue;
    }
}*/
